home *** CD-ROM | disk | FTP | other *** search
- // A cheep file prompt for selecting PGN files.
- //
- // History
- // 1996/03/11 RMF Updated for PPC and set SIOUXSetting
- // 1995/09/05 By R. Mark Fleming <markf@post.queensu.ca>\
- // Provide the basic file select to replace unix command line prompt.
- //
- #include <stdlib.h>
- #include <stdio.h>
- #include <unix.h> // _fcreator & __ftype
- #include <sioux.h>
-
- #include <Files.h>
- #include <LowMem.h>
- #include <StandardFile.h>
- #include <Memory.h>
- Boolean gDone = false;
-
- int _Main( int argc, char *argv[]);
- OSErr ConvertFile(StandardFileReply *reply, char *Myargv[2]);
-
- int main( int argc, char *argv[])
- {
- #pragma unused ( argc )
- #pragma unused ( argv )
- StandardFileReply reply;
- SFTypeList typeList;
- OSErr err = noErr;
- char *Myargv[2];
- Str255 appName;
-
-
- /* Don’t exit the program after it runs or ask whether to save the window when the program exit */
- SIOUXSettings.autocloseonquit = FALSE;
- SIOUXSettings.asktosaveonclose = FALSE;
- /* Don’t show the status line */
- SIOUXSettings.showstatusline = FALSE;
- /* Make the window large enough to fit 1 line of text that contains 12 characters. */
- SIOUXSettings.columns = 80; SIOUXSettings.rows = 24;
- SIOUXSettings.toppixel = 40; SIOUXSettings.leftpixel = 5;
- SIOUXSettings.tabspaces = 4;
-
- SIOUXSettings.autocloseonquit = TRUE;
- SIOUXSettings.asktosaveonclose = TRUE;
-
- SIOUXSettings.standalone = FALSE;
- SIOUXSettings.setupmenus = TRUE;
-
- /* When you want to initialize the Macintosh Toolbox yourself, set the field initializeTB to FALSE. */
- SIOUXSettings.initializeTB = TRUE;
-
- BlockMoveData((Ptr)LMGetCurApName(), (Ptr)appName, sizeof(Str31)); // Get the current application name
- p2cstr(appName);
- Myargv[0] = (char *) &appName[0]; // Arg[0] = application name
- Myargv[1] = (char *)reply.sfFile.name; // Arg[1] = the file to translate
-
- fprintf(stderr, "%s V1.0, Freeware, convert to Macintosh\r\nby Mark Fleming <Markf@post.queensu.ca>\r\n", appName);
- fprintf(stderr, "\r\nfor updates check out:\n\r\t<http://ccsmacinfo.ccs.queensu.ca/Mark/>\n");
-
-
- StandardGetFile(nil, -1, typeList, &reply);
- while (reply.sfGood && err == noErr) {
- err = ConvertFile(&reply, Myargv);
- if (err != noErr) SysBeep(0); /* End if Err */
-
- StandardGetFile(nil, -1, typeList, &reply);
- } // End while()
-
- return err;
- } /* End of () */
-
- OSErr ConvertFile(StandardFileReply *reply, char *Myargv[2])
- { OSErr err;
- short savedVol;
-
- err = GetVol(0, &savedVol);
- if (err == noErr) {
- err = HSetVol(0, reply->sfFile.vRefNum, reply->sfFile.parID);
- if (err == noErr) {
- p2cstr(reply->sfFile.name);
-
- fprintf(stderr, "\r\nProcessing file: %s\r\n", Myargv[1]);
-
- _Main(2, Myargv);
-
- c2pstr((char*)reply->sfFile.name);
- }
- SetVol(0, savedVol);
- }
- return err;
- } // end of ConvertFile()
-
-